Class sjl.BackInsertIterator
All Packages Class Hierarchy This Package Previous Next Index
Class sjl.BackInsertIterator
java.lang.Object
|
+----sjl.Iter
|
+----sjl.BackInsertIterator
- public class BackInsertIterator
- extends Iter
- implements OutputIterator
An iterator adapter that causes all assignment operations (put) to be
converted into an push_back()
operation.
When the BackInsertIterator
is constructed a container
which implements the
BackInsertContainer interface must
be supplied.
Currently the List, the
Deque and the Vector
implements BackInsertContainer
.
Copyright © 1996 Finn Bock
- See Also:
- List, Deque, Vector
-
BackInsertIterator(BackInsertContainer)
- Construct an insert iterator for the container, which convert all
assigments (put) into the
push_back
method.
-
cmp(Iterator)
- Invalid.
-
genericCopy()
- Return this.
-
next()
- Do nothing.
-
put(Object)
- Insert object at the end of the container.
-
setTo(Iterator)
- Assign this iterator to another container.
BackInsertIterator
public BackInsertIterator(BackInsertContainer container)
- Construct an insert iterator for the container, which convert all
assigments (put) into the
push_back
method.
The container must be a BackInsertContainer
, that is,
it must support the push_back
method.
put
public Object put(Object object)
- Insert object at the end of the container.
- Parameters:
- object - The object that will be inserted in the container
- Returns:
- object is returned.
next
public Iterator next()
- Do nothing. All assignment to this iterator will always be at the
back of the container, so advancing the iterator is ignored.
cmp
public boolean cmp(Iterator i)
- Invalid. This method is inherited from Iterator, but should
not exist in an OutputIterator.
XXX: Throw an exception perhaps??.
genericCopy
public Iterator genericCopy()
- Return this. Since insert iterators does not maintain any position,
there is no need for actually clone the iterator.
setTo
public void setTo(Iterator i)
- Assign this iterator to another container. This is faster than creating
a new BackInsertIterator object.
All Packages Class Hierarchy This Package Previous Next Index